package com.zys.el.time.mapper;

import com.zys.el.time.entity.ThinkingLike;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zys.el.time.entity.ThinkingLikeCount;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;


public interface ThinkingLikeMapper extends BaseMapper<ThinkingLike> {

    @Select("select * from thinking_like " +
            "where thinking_id = #{thinkingId} and user_id = #{userId};")
    ThinkingLike getByThinkingIdAndUserId(@Param("thinkingId") Long thinkingId,
                                          @Param("userId") Long userId);

    @Update("update thinking_like set status = #{status} " +
            "where thinking_id = #{thinkingId} and user_id = #{userId}")
    void updateStatusByThinkingIdAndUserId(@Param("thinkingId") Long thinkingId,
                                           @Param("userId") Long userId,
                                           @Param("status") Integer status);

    List<ThinkingLikeCount> getCountGroupByThinkingId();
}




